<?php


/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Badge
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
 
 
?>

<script type="text/javascript">
  var tabContainerSwitch = function(element) {
    if( element.tagName.toLowerCase() == 'a' ) {
      element = element.getParent('li');
    }

    var myContainer = element.getParent('.tabs_parent').getParent();

    myContainer.getChildren('div:not(.tabs_alt)').setStyle('display', 'none');
    myContainer.getElements('ul > li').removeClass('active');
    element.get('class').split(' ').each(function(className){
      className = className.trim();
      if( className.match(/^tab_[0-9]+$/) ) {
        myContainer.getChildren('div.' + className).setStyle('display', null);
        element.addClass('active');
      }
    });
  }
  var moreTabSwitch = function(el) {
    el.toggleClass('tab_open');
    el.toggleClass('tab_closed');
  }
</script>

<div class='layout_right badge_view_layout_right'>
  <div class='badges_gutter'>
    <div class='badge_award_badge'>
      <?php echo $this->htmlLink($this->badge->getHref(),
        $this->itemPhoto($this->badge, 'thumb.profile')
      )?>
      <?php echo $this->htmlLink($this->badge->getHref(),
        $this->badge->getTitle(),
        array('class' => 'badge_award_badge_title')
      )?>
    </div>  
  
    <?php if ($this->badge->getDescription()):?>
      <div class='badge_desc'>
        <h4><?php echo $this->translate('About This Badge')?></h4>
        <div><?php echo $this->viewMore($this->badge->getDescription()); ?></div>
      </div>
    <?php endif;?>
    
    <?php if ($this->canRequest): ?>
      <div class="badge_request_about">
        <div><?php echo $this->translate('Would you like to have this badge?'); ?></div>
        <?php echo $this->htmlLink(array('route'=>'badge_request_general', 'action'=>'create', 'badge_id'=>$this->badge->getIdentity()),
          $this->translate('Submit A Request'),
          array('class'=>'smoothbox buttonlink icon_badge_request')
        ); ?>
      </div>
    <?php endif; ?>
    
    
    <div class="badge_view_info">
      <h4><?php echo $this->translate('Badge Info')?></h4>
      <ul>
        <li><?php echo $this->translate('Category: %s', $this->badge->getCategory()->__toString())?></li>
        <li><?php echo $this->translate('Member Assignment: %s', $this->badge->isMembershipTypeAward() ? 'Award' : 'Mapping'); ?></li>
        <li><?php echo $this->translate('Created On: %s', $this->locale()->toDate($this->badge->creation_date))?></li>
        <li><?php echo $this->translate('Views: %s', $this->badge->view_count);?></li>
      </ul>
    </div>
    
  </div>
</div>

<div class='layout_middle badge_layout_middle'>
  <div class='badge_view'>
    <h2>
      <?php // echo $this->translate('Member\'s %1$s', $this->badge->__toString())?>
      <?php echo $this->badge->getTitle() ?>
    </h2>
    
    <div class="tabs_alt tabs_parent">
      <ul id="main_tabs">
      
        <?php if ($this->badge->isMembershipTypeAward()): ?>
          <li class="tab_110 active"><a onclick="tabContainerSwitch($(this), 'badge_view_tab_awards');" href="javascript:void(0);"><?php echo $this->translate('Awarded Members')?><span>(<?php echo $this->awardPaginator->getTotalItemCount(); ?>)</span></a></li>
        <?php endif;?>
        <?php if ($this->badge->isMembershipTypeMapping()): ?>
          <li class="tab_111 active"><a onclick="tabContainerSwitch($(this), 'badge_view_tab_members');" href="javascript:void(0);"><?php echo $this->translate('Members')?><span>(<?php echo $this->memberPaginator->getTotalItemCount(); ?>)</span></a></li>
        <?php endif; ?>
        <?php if ($this->badge->body): ?>
          <li class="tab_112"><a onclick="tabContainerSwitch($(this), 'badge_view_tab_learn_more');" href="javascript:void(0);"><?php echo $this->translate('Learn More')?></a></li>                                                                                                                                                                                         
        <?php endif; ?>
        <?php if ($this->badge->requirement_tab_display): ?>
          <li class="tab_113"><a onclick="tabContainerSwitch($(this), 'badge_view_tab_requirements');" href="javascript:void(0);"><?php echo $this->translate('Requirements')?></a></li>                                                                                                                                                                                         
        <?php endif; ?>
      </ul>
    </div>    
    
    
    <?php if ($this->badge->isMembershipTypeAward()): ?>
      <div class='tab_110 badge_view_tab_awards badge_awards'>
  
        <?php if( $this->awardPaginator->getTotalItemCount() > 0 ): ?>
          <ul class='badge_members_list'>
            <?php foreach ($this->awardPaginator as $award): ?>
              <?php 
                $user = $award->getUser();
              ?>
              
              <?php if ($this->badge->award_members_simple): ?>
                <li class="badge_award_members_simple">
                <?php echo $this->htmlLink($user->getHref(), $this->itemPhoto($user, 'thumb.icon')) ?>
                <?php if( $this->viewer()->getIdentity() ): ?>
                  <div class='badge_view_tab_members_links'>
                    <?php echo $this->userFriendship($user) ?>
                  </div>
                <?php endif; ?>
                  <div class='badge_view_tab_members_info'>
                    <?php echo $this->htmlLink($user->getHref(), $user->getTitle()) ?>
                    <?php echo $user->status; ?>
                    <?php if( $user->status != "" ): ?>
                      <div>
                        <?php echo $this->timestamp($user->status_date) ?>
                      </div>
                    <?php endif; ?>
                      <div>
                        <?php echo $this->translate('Joined %s', $this->timestamp($user->creation_date))?>
                        -
                        <?php echo $this->translate(array('%s view', '%s views', $user->view_count), $user->view_count)?>
                        -
                        <?php echo $this->translate(array('%s invite', '%s invites', $user->invites_used), $user->invites_used)?>
                      </div>
                  </div>
                </li>  
              <?php else: ?>
                <li>
                  <div class='badge_member_photo'>
                    <?php echo $this->htmlLink($user->getHref(), $this->itemPhoto($user, 'thumb.icon'));?>
                  </div>
                  <div class='badge_member_user'>
                    <?php echo $this->htmlLink($user->getHref(), $user->getTitle(), array('class'=>'badge_member_user_title')); ?>
                    <div class='badge_award_meta'>
                      <?php echo $this->translate('Awarded on %s', $this->locale()->toDate($award->creation_date)); ?>
                    </div>
                  </div>
                  <div class='badge_member_award'>
                    <div class='badge_award_title'>
                      <?php echo $award->__toString(); ?>
                    </div>
                    <div class='badge_award_meta'>
                      <?php echo $this->translate(array("%s comment", "%s comments", $award->comment_count), $this->locale()->toNumber($award->comment_count)); ?>
                      -
                      <?php echo $this->translate(array('%1$s like', '%1$s likes', $award->like_count), $this->locale()->toNumber($award->like_count)); ?>
                      -
                      <?php echo $this->translate(array("%s view", "%s view", $award->view_count), $this->locale()->toNumber($award->view_count)); ?>
                      
                    </div>
                    <div class='badge_award_desc'>
                      <?php echo $this->viewMore($award->getDescription()); ?>
                    </div>
                  </div>
                </li>
              <?php endif; ?>
              
            <?php endforeach; ?>
          </ul>
          
          <?php echo $this->paginationControl($this->awardPaginator, null, null, array(
           // 'query' => $this->formValues
          )); ?>   
          
        <?php else: ?>
          <div class="tip">
            <span>
              <?php echo $this->translate('This badge does not have any awarded members yet.');?>
            </span>
          </div>
        <?php endif; ?>
          
      </div>
    <?php endif; ?>    
    
    <?php if ($this->badge->isMembershipTypeMapping()): ?>
      <div class='tab_111 badge_view_tab_members badge_awards'>
  
        <?php if( $this->memberPaginator->getTotalItemCount() > 0 ): ?>
          <ul class='badge_members_list'>
            <?php foreach( $this->memberPaginator as $user ): ?>
              <li>
                <?php echo $this->htmlLink($user->getHref(), $this->itemPhoto($user, 'thumb.icon')) ?>
                <?php if( $this->viewer()->getIdentity() ): ?>
                  <div class='badge_view_tab_members_links'>
                    <?php echo $this->userFriendship($user) ?>
                  </div>
                <?php endif; ?>
          
                  <div class='badge_view_tab_members_info'>
                    <?php echo $this->htmlLink($user->getHref(), $user->getTitle()) ?>
                    <?php echo $user->status; ?>
                    <?php if( $user->status != "" ): ?>
                      <div>
                        <?php echo $this->timestamp($user->status_date) ?>
                      </div>
                    <?php endif; ?>
                      <div>
                        <?php echo $this->translate('Joined %s', $this->timestamp($user->creation_date))?>
                        -
                        <?php echo $this->translate(array('%s view', '%s views', $user->view_count), $user->view_count)?>
                        -
                        <?php echo $this->translate(array('%s invite', '%s invites', $user->invites_used), $user->invites_used)?>
                      </div>
                  </div>
              </li>
            <?php endforeach; ?>
          </ul>
          
          <?php echo $this->paginationControl($this->memberPaginator, null, null, array(
           // 'query' => $this->formValues
          )); ?>   
          
        <?php else: ?>
          <div class="tip">
            <span>
              <?php echo $this->translate('This badge does not have any members.');?>
            </span>
          </div>
        <?php endif; ?>
          
      </div>
    <?php endif; ?>
    
    

    <?php if ($this->badge->body): ?>
      <div class="tab_112 badge_view_tab_learn_more" style="display: none">
        <?php echo $this->badge->body; ?>
      </div>
    <?php endif;?>
    
    <?php if ($this->badge->requirement_tab_display): ?>
      <div class="tab_113 badge_view_tab_requirements" style="display: none">
        <p><?php echo $this->translate('In order to have this badge, members must meet the following requirements:')?></p>
        <table>
          <tr>
            <th><?php echo $this->translate('Profile Photo:')?></th>
            <td>
              <?php echo $this->translate( $this->badge->user_profile_photo ? 'Must upload photo' : 'not required')?>
            </td>
          </tr>
          <tr>
            <th><?php echo $this->translate('Minimum Profile Views:')?></th>
            <td>
              <?php echo $this->badge->user_view_count; ?>
            </td>
          </tr>
          <tr>
            <th><?php echo $this->translate('Minimum Invites Sent:')?></th>
            <td>
              <?php echo $this->badge->user_invites_used;?>
            </td>
          </tr>
          <tr>
            <th><?php echo $this->translate('Signup Days:')?></th>
            <td>
              <?php if ($this->badge->user_account_age): ?>
                <?php echo $this->translate(array('been a member for %s day','been a member for %s days',$this->badge->user_account_age), $this->badge->user_account_age);?>
              <?php else: ?>
                <?php echo $this->translate('not required'); ?>
              <?php endif; ?>
            </td>
          </tr>
          <tr>
            <th><?php echo $this->translate('Member Last Logged In:')?></th>
            <td>
              <?php if ($this->badge->user_login_days): ?>
                <?php echo $this->translate(array('must log in within last %s day','must log in within last %s days',$this->badge->user_login_days), $this->badge->user_login_days);?>
              <?php else: ?>
                <?php echo $this->translate('not required'); ?>
              <?php endif; ?>
            </td>
          </tr>
          <tr>
            <th><?php echo $this->translate('Member Level:')?></th>
            <td>
              <?php if ($this->badge->user_level_settings): ?>
                <?php echo join('<br/>', $this->badge->getInfoMemberLevels()); ?>
              <?php else: ?>
                <?php echo $this->translate('Any Member Levels')?>
              <?php endif;?>
            </td>
          </tr>
          <tr>
            <th><?php echo $this->translate('Member Network:')?></th>
            <td>
              <?php if ($this->badge->user_network_settings): ?>
                <?php echo join('<br/>', $this->badge->getInfoMemberNetworks()); ?>
              <?php else: ?>
                <?php echo $this->translate('Any Member Networks')?>
              <?php endif;?>
            </td>
          </tr>
          <tr>
            <th><?php echo $this->translate('Member Profile Type:')?></th>
            <td>
              <?php if ($this->badge->user_profile_settings): ?>
                <?php echo join('<br/>', $this->badge->getInfoMemberProfiles()); ?>
              <?php else: ?>
                <?php echo $this->translate('Any Member Profile Types')?>
              <?php endif;?>
            </td>
          </tr>
        </table>
      </div>
    <?php endif; ?>
  </div>
</div>